// pages/timechoose/timechoose.js
const db = wx.cloud.database()

Page({

    /**
     * 页面的初始数据
     */
    data: {
        time_id: '',
        year: '',
        month: '',
        day: '',
        xs: '',
        fz: '',
        timechoose: '',
    },
    //时间
    attached() {
        const date = new Date();
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
        var xs = date.getHours();//获取小时
        var fz = date.getMinutes();
        this.setData({
            year: year,
            month: month,
            day: day,
            xs: xs,
            fz: fz,
        });
    },
    //选择座位
    seat_choose(e) {
        console.log(e.currentTarget)
        let value1 = e.currentTarget.dataset.value1
        let value2 = e.currentTarget.dataset.value2
        wx.navigateTo({
            url: '../seat_choose/seat_choose?value1=' + value1 + "&value2=" + value2,
        })
    },
    //获取时间信息
    gettime() {
        db.collection("time").where({cg_name: this.data.time_id}).get().then(res => {
            console.log(res)
            this.setData({
                timechoose: res.data,
            })
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            time_id: options.time_id,
        })
        this.attached()
        this.gettime()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})